package com.tom.baselibrary.base;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.fragment.app.Fragment;

import com.tom.baselibrary.ioc.ViewUtils;

/**
 * Added by Tom on 2024/07/15.
 * 整个应用的BaseFragment，使用模板设计模式。
 */
public abstract class BaseFragment extends Fragment {

    protected View rootView;
    protected Context context;


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        this.context = getActivity();
        this.rootView = View.inflate(context, getLayoutId(), null);
        // 加入注解的支持
        ViewUtils.inject(rootView, this);

        return rootView;
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

        initView();
        initData();
    }

    protected abstract void initView();

    protected abstract void initData();

    protected abstract int getLayoutId();


    // 判断后台返回的数据，是否成功
//    protected boolean isNetRequestOk(BaseResult result) {
//        return result.message.equals("success");
//    }

}
